Subroutine CheckRunMode(RNMODE)

  Implicit None
  INTEGER COUNT
  CHARACTER*1 RNMODE
  CHARACTER*120 MSG(67)

  DATA MSG / &
  "-----------------------------------------------------------------------------", &
  "DSSAT COMMAND LINE USAGE:                                                    ", & 
  "                                                                             ", &
  "  dscsm048 <model> runmode <argA> <argB> <control_file>                      ", &
  "                                                                             ", &
  "-----------------------------------------------------------------------------", &
  "Details:                                                                     ", &
  "  <model>   - OPTIONAL                                                       ", &
  "            - 8-character name of crop model (e.g., MZIXM048 or WHAPS048).   ", &
  "            - If model name is blank or invalid, the default will be used.   ", &
  "                                                                             ", &
  "  runmode   - REQUIRED                                                       ", &
  "            - 1-character run mode code                                      ", &
  "            - see table below for valid values of argA and argB              ", &
  "                                                                             ", &
  "  <control_file> - OPTIONAL                                                  ", &
  "            - path + filename of external file which contains overrides for  ", &
  "                simulation controls.                                         ", &
  "            - This option is available with all run modes except D and I.    ", &
  "            - Default file (DSCSM048.CTR) is found in DSSAT root directory.  ", &
  "            - see https://dssat.net/using-an-external-simulation-control-file", &
  "            - 120 characters maximum.                                        ", &
  "run                                                                          ", &
  "mode argA       argB  Description                                            ", &
  "---- ---------  ----- ------------------------------------------------------ ", &
  " A   FileX      NA    All: Run all treatments in the specified FileX.        ", &
  " B   BatchFile  NA    Batch: Batchfile lists experiments and treatments.     ", &
  " C   FileX      TrtNo Command line: Run single FileX and treatment #.        ", &
  " D   TempFile   NA    Debug: Skip input module and use existing TempFile.    ", &
  " E   BatchFile  NA    Sensitivity: Batchfile lists FileX and TrtNo.          ", &
  " F   BatchFile  NA    Farm model: Batchfile lists experiments and treatments.", &
  " G   FileX      TrtNo Gencalc: Run single FileX and treatment #.             ", &
  " I   NA         NA    Interactive: Interactively select FileX and TrtNo.     ", &
  " L   BatchFile  NA    Gene-based model (Locus): Batchfile for FileX and TrtNo", &
  " N   BatchFile  NA    Seasonal analysis: Batchfile lists FileX and TrtNo.    ", &
  " Q   BatchFile  NA    Sequence analysis: Batchfile lists FileX & rotation #. ", &
  " S   BatchFile  NA    Spatial: Batchfile lists experiments and treatments.   ", &
  " T   BatchFile  NA    Gencalc: Batchfile lists experiments and treatments.   ", &
  " Y   BatchFile  NA    Yield forecast mode uses ensemble weather data.        ", &
  "                                                                             ", &
  "  BatchFile - Name of DSSAT batch file with list of exeriments and treatments", &
  "                (e.g., DSSBATCH.v47)                                         ", &
  "            - Current directory, 30 characters maximum                       ", &
  "                                                                             ", &
  "  FileX     - Name of Experimental file (e.g., UFGA7801.SBX)                 ", &
  "            - Current directory, 12-character DSSAT naming convention        ", &
  "                                                                             ", &
  "  TempFile  - Name of temporary I/O file, normally generated by the input    ", &
  "                module (e.g., DSSAT47.INP)                                   ", &
  "            - Current directory, 30 characters maximum                       ", &
  "                                                                             ", &
  "  TrtNo     - Treatment # (integer) in specified FileX to be simulated       ", &
  "                                                                             ", &
  "-----------------------------------------------------------------------------", &
  " Example #1:                                                                 ", &
  " DSCSM048 B DSSBATCH.V48                                                     ", &
  " Effect: Run in batch mode. Name of the batch file is DSSBATCH.V47.          ", &
  "                                                                             ", &
  " Example #2:                                                                 ", &
  " DSCSM048 MZIXM048 A UFGA8201.MZX                                            ", &
  " Effect: Run all treatments in experiment UFGA8201.MZX using IXIM model.     ", &
  "                                                                             ", &
  " Example #3:                                                                 ", &
  " DSCSM048 Q DSSBATCH.V48 DSCSM048.CTR                                        ", &
  " Effect: Run sequence simulation listed in DSSBATCH.V47 using the            ", &
  "           simulation control options specified by DSCSM048.CTR              ", &
  "-----------------------------------------------------------------------------"/

  IF (INDEX('ABCDEFGILNQSTYabcdefginlqsty',RNMODE) .GT. 0) RETURN

  COUNT = SIZE(MSG)
  WRITE(*,'(100(/,A))') MSG
  CALL WARNING(COUNT, "CSM", MSG)
  CALL ERROR ("CSM",90,"",0)
  RETURN
End Subroutine CheckRunMode
